package com.kaifamiao.map;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class PropertiesTest2 {

    public static void main(String[] args) throws IOException {

        Properties props = new Properties();

        String pathname = "D:/kaifamiao/codes/java-basics/map/src/com/kaifamiao/map/db.properties";
        InputStream in = new FileInputStream( pathname );
        props.load( in );

        /*
        Enumeration e = props.propertyNames();
        Iterator itor = e.asIterator();
        while( itor.hasNext() ) {
            String name = (String)itor.next();
            String value = props.getProperty( name );
            System.out.printf( "%s = %s\n" , name , value );
        }
        */

        /*
        Set<String> names = props.stringPropertyNames();
        for ( String name : names ) {
            String value = props.getProperty( name );
            System.out.printf( "%s = %s\n" , name , value );
        }
        */

        System.out.println( props.getProperty( "connect" ) );

        String driver = props.getProperty( "jdbc.connection.mysql.driver" );
        System.out.println( driver );

        String url = props.getProperty( "jdbc.connection.mysql.url" );
        System.out.println( url );

        String user = props.getProperty( "jdbc.connection.mysql.user" );
        System.out.println( user );

        String password = props.getProperty( "jdbc.connection.mysql.password" );
        System.out.println( password );
    }

}
